package com.todo.event.activity.application.backend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.event.activity.application.backend.service.EventActivityBackendService;
import com.todo.event.activity.iface.backend.EventActivityBackendIface;
import com.todo.event.activity.iface.backend.request.*;
import com.todo.event.activity.iface.backend.response.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2025/1/11 20:56
 * @description
 */
@RestController
@RequestMapping("/bd/event/activity")
@Tag(name = "事件活动配置后台处理类", description = "事件活动配置后台处理类")
public class EventActivityBackendController implements EventActivityBackendIface {

    @Resource
    private EventActivityBackendService eventActivityBackendService;

    @Override
    @Operation(summary = "新增事件活动")
    @PostMapping("/insertEventActivity")
    public BizResponse<Boolean> insertEventActivity(@RequestBody InsertEventActivityReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventActivityBackendService.insertEventActivity(req);
    }

    @Override
    @Operation(summary = "更新事件活动")
    @PostMapping("/updateEventActivity")
    public BizResponse<Boolean> updateEventActivity(@RequestBody UpdateEventActivityReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventActivityBackendService.updateEventActivity(req);
    }

    @Override
    @Operation(summary = "根据主键删除事件活动")
    @PostMapping("/removeEventActivityById")
    public BizResponse<Boolean> removeEventActivityById(@RequestBody RemoveEventActivityByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventActivityBackendService.removeEventActivityById(req);
    }

    @Override
    @Operation(summary = "根据主键查询事件活动详情")
    @PostMapping("/queryEventActivityById")
    public BizResponse<EventActivityDetailResp> queryEventActivityById(@RequestBody QueryEventActivityByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventActivityBackendService.queryEventActivityById(req);
    }

    @Override
    @Operation(summary = "事件活动测试验证")
    @PostMapping("/testEventActivityProperty")
    public BizResponse<Boolean> testEventActivityProperty(@RequestBody TestEventActivityPropertyReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventActivityBackendService.testEventActivityProperty(req);
    }

    @Override
    @Operation(summary = "启用事件活动")
    @PostMapping("/enableEventActivity")
    public BizResponse<Boolean> enableEventActivity(@RequestBody EnableEventActivityReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventActivityBackendService.enableEventActivity(req);
    }

    @Override
    @Operation(summary = "分页多条件查询事件活动基础信息")
    @PostMapping("/queryEventActivityPage")
    public BizPageResponse<EventActivityInfoResp> queryEventActivityPage(@RequestBody QueryEventActivityPageReq req) {
        if (req == null) {
            return BizPageResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizPageResponse.paramError("参数错误");
        }
        return eventActivityBackendService.queryEventActivityPage(req);
    }

    @Override
    @Operation(summary = "查询执行奖励记录")
    @PostMapping("/queryEAExecuteRewardRecord")
    public BizResponse<List<EAExecuteRewardRecordResp>> queryEAExecuteRewardRecord(@RequestBody QueryEAExecuteRewardRecordReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventActivityBackendService.queryEAExecuteRewardRecord(req);
    }

    @Override
    @Operation(summary = "查询执行触达记录")
    @PostMapping("/queryEAExecuteTouchRecord")
    public BizResponse<List<EAExecuteTouchRecordResp>> queryEAExecuteTouchRecord(@RequestBody QueryEAExecuteTouchRecordReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventActivityBackendService.queryEAExecuteTouchRecord(req);
    }

    @Override
    @Operation(summary = "查询执行流程各节点执行记录")
    @PostMapping("/queryEAExecuteFlowPoint")
    public BizResponse<List<EAExecuteFlowPointResp>> queryEAExecuteFlowPoint(@RequestBody QueryEAExecuteFlowPointReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventActivityBackendService.queryEAExecuteFlowPoint(req);
    }
}
